package ke05;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileCopy7 {

	public void copy(String src, String dest){
		
		// try with resources
		try (FileInputStream fis = new FileInputStream(src);
				FileOutputStream fos = new FileOutputStream(dest)) {
			
			
			int ava = fis.available();
			byte[] buffer = new byte[ava];
			int len = 0;
			while(len != -1){
				len = fis.read(buffer);
				if(len != -1){
					fos.write(buffer);
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		new FileCopy().copy("fileWriter.txt", "FileWriterCopy.txt");
	}

}
